package net.cloudsun.graph.puzzle.group;

import net.cloudsun.graph.group.AbstractGroupBuilder;
import net.cloudsun.graph.puzzle.JigsawState;

/**
 * 创建群
 * created at 23/11/2021
 *
 * @author 俞建波
 * <a href="mailto://yujianbo@chtwm.com">yujianbo@chtwm.com</a>
 * @since 1.1.0
 */
public class PuzzleRotateGroupBuilder extends AbstractPuzzleGroupBuilder<PuzzleRotateGroup> {

    private int centerNumber;

    public PuzzleRotateGroupBuilder(int centerNumber) {
        this.centerNumber = centerNumber;
    }

    @Override
    protected int compare(JigsawState jigsawState, JigsawState t1) {
        return jigsawState.compareTo(t1);
    }

    @Override
    protected boolean check(String line) {
        // 0 1 2 3 4 5 6 7 8
        final char c = line.charAt(4);
        return Integer.parseInt(String.valueOf(c)) == centerNumber;
    }

    @Override
    protected PuzzleRotateGroup newGroup(JigsawState element) {
        return new PuzzleRotateGroup();
    }
}
